import request from '@/utils/request2'

// 查询数据库连接列表
export function listDatasource(query) {
  return request({
    url: '/datasource/datasource/list',
    method: 'get',
    params: query
  })
}

// 查询数据库连接详细
export function getDatasource(id) {
  return request({
    url: '/datasource/datasource/' + id,
    method: 'get'
  })
}
export function getDatasourceConne(id) {
  return request({
    url: '/datasource/datasource/conn/' + id,
    method: 'get'
  })
}

// 新增数据库连接
export function addDatasource(data) {
  return request({
    url: '/datasource/datasource',
    method: 'post',
    data: data
  })
}

// 修改数据库连接
export function updateDatasource(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/datasource/datasource/edit',
    method: 'POST',
    data: JSON.stringify(data)
  })
}

// 删除数据库连接
export function delDatasource(id) {
  return request({
    url: '/datasource/datasource/remove/' + id,
    method: 'GET'
  })
}

// 导出数据库连接
export function exportDatasource(query) {
  return request({
    url: '/datasource/datasource/export',
    method: 'get',
    params: query
  })
}
export function selectTableByEnName(data,tableName) {
  var url='/datasource/datasource/table/'+data
  if(tableName){
    url=url+'?tableName='+tableName
  }else{


  }
  return request({
    url: url,
    method: 'get',

  })
}
export function getDataByTableNameAndDataSource(data) {
  return request({
    url: '/datasource/datasource/dataSet/getData/'+data.id+"/"+data.type+'/'+data.tableName,
    method: 'GET',
  })
}
export function synchronizationData(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/api/synchronization/excute',
    method: 'POST',
    data: JSON.stringify(data)
  })
}

export function importExcle(data) {
  return request({
    headers:{
      'Content-Type': 'multipart/form-data'
    },
    url: '/uc/api/user/importExcle',
    method: 'post',
    data: data
  })
}


